<?php
namespace Controller;
use Kuyuan\WqCore\controller\Controller;
use Model\W7McMappingFansModel;

/**
 * 公众号相关操作
 * Class WeChat
 * @package Controller
 */
class WeChat extends Controller
{
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * 指定用户是否关注了公众号
     * @param int uid 用户id
     * @return mixed
     */
    public function testAttention($_uid = 0)
    {
        if(!$_uid) $_uid = $this->_uid;
        $AccountApi = \WeAccount::create();
        $_openid = W7McMappingFansModel::where("uid", $_uid)->cache(!KUYUAN_DEBUG)->value("openid");
        $_fans = $AccountApi->fansQueryInfo($_openid);
        return $_fans["subscribe"];
    }

    /**
     * 获取关注公众后的二维码
     */
    public function getAttentionQrcode()
    {
        return $this->_w["uniaccount"]["qrcode"];
    }
}